package com.igeek.base.ch0715.Demo2;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import java.util.Scanner;

/**
 * @Description TODO
 * @Author chenmin
 * @Date 2024/7/15 20:37
 */
public class Text {

    public static Student transfer(String line){
        Student student = new Student();
        String[] arr=line.split(",");
        int id =Integer.parseInt(arr[1]);
        student.setId(id);
        student.setName(arr[0]);
        LocalDate birthday = LocalDate.parse(arr[2], DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        student.setBirthday(birthday);
        return student;

    }
    public static void main(String[] args) {
        ArrayDao dao = new ArrayDao();
        Scanner scanner = new Scanner(System.in);

        while (true) {
            String line = scanner.next();
            Student student = transfer(line);
            if (!dao.stus.contains(student)) {
                dao.stus.add(student);
            }else {
                System.out.println("该学生已存在，无法重复添加。");
                break;
            }
        }
    }
}
